//
//  ScanResultView.m
//  SmartWatch
//
//  Created by zwj on 2022/11/24.
//

#import "ScanResultView.h"

@implementation ScanResultView

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        self.backgroundColor = COLOR_4;
        ViewCorner(self, 15);
        
        MyLinearLayout *root = [MyLinearLayout linearLayoutWithOrientation:MyOrientation_Vert];
        root.myHorzMargin = 15;
        root.myHeight = kAutoHeight;
        root.myTop = 36;
        root.gravity = MyGravity_Horz_Center;
        root.subviewVSpace = 15;
        [self addSubview:root];
        
        UIImageView *avatar = [[UIImageView alloc]initWithImage:UIImageMake(@"avatar")];
        avatar.mySize = CGSizeMake(76, 76);
        [root addSubview:avatar];
        
        QMUIButton * nameBtn = [QMUIButton buttonWithType:UIButtonTypeCustom];
        [nameBtn setImage:UIImageMake(@"profile_nv") forState:UIControlStateNormal];
        nameBtn.mySize = kAutoSize;
        [nameBtn setTitle:@"周晓咏" forState:UIControlStateNormal];
        [nameBtn setTitleColor:COLOR1515 forState:UIControlStateNormal];
        nameBtn.titleLabel.font = UIFontMake(16);
        nameBtn.imagePosition = QMUIButtonImagePositionRight;
        nameBtn.spacingBetweenImageAndTitle = 8;
        [root addSubview:nameBtn];
        
        NSArray *array = @[@"出生日期",@"身高",@"体重",@"联系方式"];
        for (int i = 0; i < array.count; i++) {
            MyLinearLayout *item = [MyLinearLayout linearLayoutWithOrientation:MyOrientation_Horz];
            item.myHorzMargin = 0;
            item.gravity = MyGravity_Vert_Center | MyGravity_Horz_Between;
            item.myHeight = kAutoHeight;
            item.myTop = i==0?20:0;
            [root addSubview:item];
            
            UILabel *name = [UILabel createLabelText:array[i] font:UIFontMake(14) textColor:COLOR999];
            name.mySize = kAutoSize;
            [item addSubview:name];
            
            UILabel *content = [UILabel createLabelText:@"1985-09-20" font:UIFontMake(14) textColor:COLOR1515];
            content.mySize = kAutoSize;
            [item addSubview:content];
        }
        
        MyLinearLayout *bottom = [MyLinearLayout linearLayoutWithOrientation:MyOrientation_Horz];
        bottom.myHorzMargin = 0;
        bottom.myHeight = 44;
        bottom.myTop = 10;
        bottom.gravity = MyGravity_Horz_Center | MyGravity_Vert_Center;
        bottom.backgroundColor = UIColor.whiteColor;
        bottom.layer.cornerRadius = 6;
        bottom.layer.shadowColor = [UIColor colorWithRed:222/255.0 green:238/255.0 blue:238/255.0 alpha:0.8000].CGColor;
        bottom.layer.shadowOffset = CGSizeMake(0,1);
        bottom.layer.shadowOpacity = 1;
        bottom.layer.shadowRadius = 8;
        [root addSubview:bottom];
        
        
        {
            UIImageView *sex = [[UIImageView alloc]initWithImage:UIImageMake(@"profile_report_logo")];
            sex.mySize = CGSizeMake(18, 18);
            [bottom addSubview:sex];
            
            UILabel *name = [UILabel createLabelText:@"TA的健康报告" font:UIFontMake(14) textColor:COLOR1515];
            name.mySize = kAutoSize;
            [bottom addSubview:name];
            
            UIImageView *right = [[UIImageView alloc]initWithImage:UIImageMake(@"icon_arrow_right")];
            right.mySize = CGSizeMake(16, 16);
            [bottom addSubview:right];
            
        }
        
        UIButton *attention = [UIButton createButtonText:@"关注" font:UIFontMake(14) textColor:THEME_COLOR];
        attention.myTop = 10;
        attention.mySize = CGSizeMake(108, 34);
        ViewCorner(attention, 17);
        ViewBorder(attention, 1, THEME_COLOR);
        [root addSubview:attention];
    }
    return self;
}

@end
